<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="../static/css/toastr.min.css">
    <script src="../static/js/jquery.min.js"></script>
    <script src="../static/js/toastr.min.js"></script>
    <title>flask文件上传测试1</title>
</head>

<body>
<form method="POST" action="/upload" enctype="multipart/form-data">
    <input type="file" name="file" id="file">
    <input type="submit" value="upload">
    <a href=""></a>
</form>
<hr>
<ol id="filelist">
</ol>
<script>
    function checkstatus() {
        if ('{{status}}' == 'OK') {
            toastr['success']("上传成功");
        } else if ('{{status}}' == 'null') {
            toastr['error']("上传失败");
        }
    }

    function get_list() {
        $.ajax({
            url: '/getlist',
            type: 'GET',
            success: function (result) {
                $.each($.parseJSON(result), function (index, val) {
                    $("#filelist").append(val).append('</br>')
                })
            },
            error: function () {
                alert("失败");
            }
        });
    }

    checkstatus();
    get_list();
</script>
</body>

</html>
